package com.zsrt.java.ex;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

public class EmpDao {
	
	public ArrayList FindAllEmp(){
		ArrayList list=new ArrayList();
		Connection con=DBManager.getConnection();
		System.out.println("链接成功");
		
		
		try {
			Statement st=(Statement) con.createStatement();
			ResultSet rs=st.executeQuery("select * from emp");
			while(rs!=null && rs.next()){
				Emp e=new Emp();
				e.setEid(rs.getInt("eid"));
				e.setEname(rs.getString("ename"));
				e.setSex(rs.getString("sex"));
				e.setAge(rs.getString("age"));
				
				list.add(e);
				
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
	

}
